interface IStoreData {
   expire?: number
   [key: string]: any
}
export class Store {
   public setStorage(key: string, value: IStoreData) {
      if (value.expire) {
         value.expire = new Date().getTime() + value.expire * 1000
      }
      localStorage.setItem(key, JSON.stringify(value))
   }

   public getStorage(key: string): null | IStoreData {
      const item = localStorage.getItem(key)
      if (item) {
         const data = JSON.parse(item) as IStoreData
         const expire = data.expire
         if (expire! < new Date().getTime()) {
            localStorage.removeItem(key)
            return null
         }
         return data
      }

      return null
   }
}
